/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.lacibMusic.entidades;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author AlanmLira
 */
@Entity
@Table(name = "Album")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Album.findAll", query = "SELECT a FROM Album a"),
    @NamedQuery(name = "Album.findById", query = "SELECT a FROM Album a WHERE a.id = :id"),
    @NamedQuery(name = "Album.findByNomeAlbum", query = "SELECT a FROM Album a WHERE a.nomeAlbum = :nomeAlbum"),
    @NamedQuery(name = "Album.findByAnoGravacao", query = "SELECT a FROM Album a WHERE a.anoGravacao = :anoGravacao"),
    @NamedQuery(name = "Album.findByImgAlbum", query = "SELECT a FROM Album a WHERE a.imgAlbum = :imgAlbum"),
    @NamedQuery(name = "Album.findByGenero", query = "SELECT a FROM Album a WHERE a.genero = :genero"),
    @NamedQuery(name = "Album.findByNomeArtista", query = "SELECT a FROM Album a WHERE a.nomeArtista = :nomeArtista")})
public class Album implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Size(max = 100)
    @Column(name = "nomeAlbum")
    private String nomeAlbum;
    @Column(name = "anoGravacao")
    @Temporal(TemporalType.DATE)
    private Date anoGravacao;
    @Size(max = 200)
    @Column(name = "imgAlbum")
    private String imgAlbum;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 25)
    @Column(name = "genero")
    private String genero;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "nomeArtista")
    private String nomeArtista;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "albumid")
    private List<Disco> discoList;
    @JoinColumn(name = "Selo_id", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Selo seloid;

    public Album() {
    }

    public Album(Integer id) {
        this.id = id;
    }

    public Album(Integer id, String genero, String nomeArtista) {
        this.id = id;
        this.genero = genero;
        this.nomeArtista = nomeArtista;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getNomeAlbum() {
        return nomeAlbum;
    }

    public void setNomeAlbum(String nomeAlbum) {
        this.nomeAlbum = nomeAlbum;
    }

    public Date getAnoGravacao() {
        return anoGravacao;
    }

    public void setAnoGravacao(Date anoGravacao) {
        this.anoGravacao = anoGravacao;
    }

    public String getImgAlbum() {
        return imgAlbum;
    }

    public void setImgAlbum(String imgAlbum) {
        this.imgAlbum = imgAlbum;
    }

    public String getGenero() {
        return genero;
    }

    public void setGenero(String genero) {
        this.genero = genero;
    }

    public String getNomeArtista() {
        return nomeArtista;
    }

    public void setNomeArtista(String nomeArtista) {
        this.nomeArtista = nomeArtista;
    }

    @XmlTransient
    public List<Disco> getDiscoList() {
        return discoList;
    }

    public void setDiscoList(List<Disco> discoList) {
        this.discoList = discoList;
    }

    public Selo getSeloid() {
        return seloid;
    }

    public void setSeloid(Selo seloid) {
        this.seloid = seloid;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Album)) {
            return false;
        }
        Album other = (Album) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "br.com.lacibMusic.entidades.Album[ id=" + id + " ]";
    }
    
}
